package io.renren.modules.app.service.impl;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.app.dao.TZnmhAppMenuDao;
import io.renren.modules.app.entity.TZnmhAppMenu;
import io.renren.modules.app.service.TZnmhAppMenuService;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TZnmhAppMenuServiceImpl extends ServiceImpl<TZnmhAppMenuDao,TZnmhAppMenu> implements TZnmhAppMenuService{
    @Autowired
    private TZnmhAppMenuDao tZnmhAppMenuDao;
    @Override
    public long getTZnmhAppMenuRowCount(){
        return tZnmhAppMenuDao.getTZnmhAppMenuRowCount();
    }

    @Override
    public PageUtils selectTZnmhAppMenuByPage(Map<String, Object> params) {
        String appMenuName = (String)params.get("appMenuName");
        String appMenuCode = (String)params.get("appMenuCode");
        String appMenuType = (String)params.get("appMenuType");
        String ascription = (String)params.get("ascription");
        String isEnable = (String)params.get("isEnable");
        Page<TZnmhAppMenu> page = this.selectPage(
                new Query<TZnmhAppMenu>(params).getPage(),
                new EntityWrapper<TZnmhAppMenu>().like(StringUtils.isNotBlank(appMenuName),"MENU_NAME",appMenuName)
                        .like(StringUtils.isNotBlank(appMenuCode),"SHORT_NAME",appMenuCode)
                        .like(StringUtils.isNotBlank(appMenuType),"MENU_TYPE",appMenuType)
                        .like(StringUtils.isNotBlank(ascription),"ASCRIPTION",ascription)
                        .like(StringUtils.isNotBlank(isEnable),"DELETE_FLAG",isEnable));
        return new PageUtils(page);
    }

    @Override
    public List<TZnmhAppMenu> selectTZnmhAppMenu(){
        return tZnmhAppMenuDao.selectTZnmhAppMenu();
    }
    @Override
    public TZnmhAppMenu selectTZnmhAppMenuByObj(TZnmhAppMenu obj){
        return tZnmhAppMenuDao.selectTZnmhAppMenuByObj(obj);
    }
    @Override
    public TZnmhAppMenu selectTZnmhAppMenuById(String id){
        return tZnmhAppMenuDao.selectTZnmhAppMenuById(id);
    }
    @Override
    public int insertTZnmhAppMenu(TZnmhAppMenu value){
        return tZnmhAppMenuDao.insertTZnmhAppMenu(value);
    }
    @Override
    public int insertNonEmptyTZnmhAppMenu(TZnmhAppMenu value){
        return tZnmhAppMenuDao.insertNonEmptyTZnmhAppMenu(value);
    }
    @Override
    public int insertTZnmhAppMenuByBatch(List<TZnmhAppMenu> value){
        return tZnmhAppMenuDao.insertTZnmhAppMenuByBatch(value);
    }
    @Override
    public int deleteTZnmhAppMenuById(String id){
        return tZnmhAppMenuDao.deleteTZnmhAppMenuById(id);
    }
    @Override
    public int updateTZnmhAppMenuById(TZnmhAppMenu enti){
        return tZnmhAppMenuDao.updateTZnmhAppMenuById(enti);
    }
    @Override
    public int updateNonEmptyTZnmhAppMenuById(TZnmhAppMenu enti){
        return tZnmhAppMenuDao.updateNonEmptyTZnmhAppMenuById(enti);
    }

    @Override
    public int deleteBatch(String[] menuIds) {
        int count = 0;
        TZnmhAppMenu tZnmhAppMenu = null;
        for(String menuId:menuIds){
            tZnmhAppMenu = new TZnmhAppMenu();
            tZnmhAppMenu.setMenuId(menuId);
            tZnmhAppMenu.setDeleteFlag("1");
            this.updateNonEmptyTZnmhAppMenuById(tZnmhAppMenu);
            count++;
        }
        return count;
    }

    public TZnmhAppMenuDao getTZnmhAppMenuDao() {
        return this.tZnmhAppMenuDao;
    }

    public void setTZnmhAppMenuDao(TZnmhAppMenuDao tZnmhAppMenuDao) {
        this.tZnmhAppMenuDao = tZnmhAppMenuDao;
    }

}